package com.itheima.consumer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    // 定义Direct队列
    @Bean
    public Queue myQueue() {
        return new Queue("myQueue", true); // true表示持久化队列
    }

    // 定义Direct交换机
    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange("test.direct");
    }

    // 绑定队列到交换机上，并指定绑定键
    @Bean
    public Binding binding(Queue myQueue, DirectExchange directExchange) {
        return BindingBuilder.bind(myQueue).to(directExchange).with("test1");
    }


}